using UnityEngine;
using UnityEngine.Events;

public class AutomaticElevator : BaseAnimatedValue
{
	public Vector3 startPoint = Vector3.zero;

	public Vector3 endPoint = Vector3.zero;

	public float secondToSendOnTheWay = 1f;

	[SerializeField]
	private UnityEvent OnFirstPoint = new UnityEvent();

	[SerializeField]
	private UnityEvent OnSecondPoint = new UnityEvent();

	[SerializeField]
	private UnityEvent OnTheWay = new UnityEvent();

	private float lastPercent = 0.5f;

	public override void SetPercent()
	{
		base.SetPercent();
		base.transform.localPosition = startPoint + (endPoint - startPoint) * base.Percent;
		if ((base.Percent == 1f || base.Percent == 0f) && lastPercent != 0f && lastPercent != 1f)
		{
			Invoke("SendOnTheWay", waitInState - secondToSendOnTheWay);
			if (base.Percent == 1f)
			{
				OnSecondPoint.Invoke();
			}
			else
			{
				OnFirstPoint.Invoke();
			}
		}
		lastPercent = base.Percent;
	}

	private void SendOnTheWay()
	{
		OnTheWay.Invoke();
	}
}
